(function(){
        let uu=document.querySelector("#acc")
        let titleArr = [];
        let contentArr = [];
        const xhr1 = new XMLHttpRequest();
        xhr1.open("get","http://chst.vip:1234/api/getcategorytitle",false);
        xhr1.onreadystatechange = function(){
            if(xhr1.readyState === 4){
                if(xhr1.status === 200){
                    let res1 = JSON.parse(xhr1.response);
                    let ele = "";
                    res1.result.forEach(item=>{
                        titleArr.push(item.titleId);
                        ele += `<li>
                                    <h4>${item.title}</h4>
                                    <div></div>
                                </li>`
                    });
                
                    uu.innerHTML = ele;
                }
            }
        }
        xhr1.send(null)

      
        titleArr.forEach(value=>{
            const xhr2 = new XMLHttpRequest();
            xhr2.open("get","http://chst.vip:1234/api/getcategory?titleid="+value,false);
            xhr2.onreadystatechange = function(){
                if(xhr2.readyState === 4){
                    if(xhr2.status === 200){
                        let res2 = JSON.parse(xhr2.response);
                        console.log(res2);
                        let divContent = ""
                        res2.result.forEach(item => {
                            divContent +=`<P>${item.category}</P>`          
                        });
                       
                        contentArr.push(divContent);
                        divContent = ""
                    }
                }
            }
            xhr2.send(null)
        })
        
        // 获取到 每个 div 给 div中 写入 存在数组中的 内容
        let aDiv = document.querySelectorAll("#acc li div")
        aDiv.forEach((item,index)=>{
            console.log(item)
            console.log(contentArr[index])
            item.innerHTML = contentArr[index];
        });
        $("#acc").find("div").slideUp(0,function(){
            $("#acc").css("display","block");
        });
        $("#acc li").click(function(){
            $(this).find("div").slideDown().parent().siblings().find("div").slideUp();
        })
        location.href = "/移动端项目/项目基本结构/html/product.html?productid=" + id
        
})()